﻿using System.Collections.Generic;
using LBoL.Base;
using LBoL.ConfigData;
using LBoL.Core;
using LBoL.Core.Battle;
using LBoL.Core.Battle.BattleActions;
using LBoLEntitySideloader.Attributes;
using ProbeMod.Cards.Template;

namespace ProbeMod.Cards
{
    public sealed class ProbeChronoWaveDef : ProbeCardTemplate
    {
        public override CardConfig MakeConfig()
        {
            var config = GetCardDefaultConfig();

            config.Rarity = Rarity.Uncommon;
            config.Type = CardType.Skill;
            config.TargetType = TargetType.Nobody;

            config.Colors = new List<ManaColor>() { ManaColor.Blue };
            config.Cost = new ManaGroup() { Blue = 2 };
            config.UpgradedCost = new ManaGroup() { Blue = 1 };

            config.Value1 = 3;  //  抽牌数
            config.Value2 = 1;  //  耐久变化值

            config.Index = CardIndexGenerator.GetUniqueIndex(config);

            return config;
        }
    }

    /// <summary>
    /// 星空加速
    /// </summary>
    [EntityLogic(typeof(ProbeChronoWaveDef))]
    public sealed class ProbeChronoWave : ProbeCard
    {
        protected override IEnumerable<BattleAction> Actions(UnitSelector selector, ManaGroup consumingMana, Interaction precondition)
        {
            yield return new DrawManyCardAction(base.Value1);
            foreach (var card in Battle.HandZone)
            {
                if (card.Config.Type == CardType.Friend)
                {
                    card.Loyalty += Value2;
                }
            }
        }
    }
}
